package com.example.android.adapter;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.android.R;
import com.example.android.bean.AddCar;
import com.example.android.bean.AddReleaseInfo;
import com.example.android.utils.ImageUrlUtil;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class AddReleaseAdapter extends BaseQuickAdapter<AddReleaseInfo, BaseViewHolder> {

    /**
     * 构造方法，此示例中，在实例化Adapter时就传入了一个List。
     * 如果后期设置数据，不需要传入初始List，直接调用 super(layoutResId); 即可
     */
    public AddReleaseAdapter(List<AddReleaseInfo> data) {
        super(R.layout.fragment_add_release, data);
    }

    /**
     * 在此方法中设置item数据
     */
    @Override
    protected void convert(@NotNull BaseViewHolder helper, @NotNull AddReleaseInfo item) {
        if (item.getPublic()){
            helper.setText(R.id.go, "修改");
            helper.setTextColor(R.id.go,Color.BLACK);
            helper.setText(R.id.number2,"已发布");
        }else {
            helper.setText(R.id.go, "发布");
            helper.setText(R.id.number2,"未发布");
            helper.setTextColor(R.id.number2, Color.RED);


        }
        helper.setText(R.id.go, item.getPublic()?"修改":"发布");
        helper.setText(R.id.textView10, item.getBrand());
        helper.setText(R.id.number, item.getPlaterNumber());
        if (item.getStartTime()!=null) {
            helper.setText(R.id.start, item.getStartTime());
        }
        if (item.getEndTime()!=null) {
            helper.setText(R.id.end, item.getEndTime());
        }
        helper.setText(R.id.textView12,item.getAddress());

        if (item.getImage()!=null) {
            Glide.with(getContext()).load(item.getImage()).into((ImageView) helper.getView(R.id.profile_image));
        }

    }

}